package controllers.participant;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.ejb.criteria.expression.function.CurrentDateFunction;

import com.google.appengine.api.datastore.Blob;

import play.data.Upload;
import play.data.validation.Valid;
import models.Focus;
import models.IdeaRequest;
import models.IdeaUnit;
import models.InformationRequest;
import models.InformationUnit;
import models.UploadFile;
import models.User;

public class IdeaRequestController extends ParticipantBaseController {
	
	/**
	 * 
	 * @param id The information request.
	 */
	public static void form(Long id) {
		IdeaRequest idea = IdeaRequest.findById(id);
		// TODO validate that this information request is available
		IdeaUnit unit = new IdeaUnit();
		
		render(idea, unit);
	}
	
	/**
	 * 
	 * @param id The information request.
	 * @param unit 
	 */
	public static void save(Long id, IdeaUnit unit, Upload[] mediaFile) {
		IdeaRequest idea = IdeaRequest.findById(id);
		unit.author = getCurrentUser();
		unit.ideaRequest = idea; // TODO validate that this information request is available
		
		unit.save();
		

		controllers.participant.IdeaRequestController.thanks(unit.id);
	}
	
	public static void thanks(Long id) {
		IdeaUnit unit = IdeaUnit.findById(id);
		render("participant/ideaRequestController/thanks.html",unit);
	}
}
